# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-pinyin-simp
pkgver=0.0.0.20230104
_commit=52b9c75f085479799553f2499c4f4c611d618cdf
pkgrel=1
pkgdesc="Simple pinyin input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-pinyin-simp"
license=('LGPL')
# dependency for reverse lookup
depends=('rime-stroke')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/rime/rime-pinyin-simp/archive/$_commit/rime-pinyin-simp-$_commit.tar.gz")
sha512sums=('4b89f9f3edd79b1220b77731eac99cf90c3496a8a09bc816ba0a40eaaae8743bd817d908492aa9ffde768b65d24a488cda558a8c8c7aa355754909420be2eead')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname-$_commit
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
